package com.ruoyi.web.controller.shopping.backend;

import com.github.pagehelper.PageInfo;
import com.ruoyi.system.domain.shopping.User;
import com.ruoyi.system.service.shopping.UserService;
import com.ruoyi.system.view.common.Result;
import com.ruoyi.system.view.common.ResultList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static com.ruoyi.common.utils.PageUtils.startPage;

@RestController
@RequestMapping("/backend/shopping/user")
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("/list")
    public ResultList<List<User>> list(User user)
    {
        startPage();
        List<User> list = userService.selectUserList(user);
        return ResultList.success(list, (int) new PageInfo(list).getTotal(),"查询成功");
    }
    @PutMapping("/changeStatus")
    public Result changeStatus(@RequestBody User user)
    {
        Boolean aBoolean = userService.updateUserStatus(user);
        if(aBoolean){
            return Result.success(null,"操作成功");
        }
        return Result.error(null,201,"操作失败");
    }


}
